package com.rockcent.mall.lib.dto;

import com.rockcent.common.domain.DtoEntity;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.common.utils.BigDecimalUtils;
import com.rockcent.common.utils.RDateFormatUtils;
import com.rockcent.common.utils.RDateUtils;
import com.rockcent.mall.lib.domain.enumclass.ProductStatus;
import com.rockcent.mall.lib.domain.enumclass.ProductType;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by DK on 16/9/18.
 * 产品管理DTO
 */
public class ProductDto extends DtoEntity {

    /**
     * 产品ID集合
     */
    private List<Long> ids;

    /**
     * 类型  ALL("全部"), GOODS("商品"), SERVICE("服务")
     */
    private String type;

    /**
     * 名称
     */

    private String name;

    /**
     * 适用/自提门店列表 ids
     */
    private List<Long> merchantStoreIds;

    /**
     * 门店列表
     */
    private String merchantStoreNames;

    /**
     * 原价
     */
    private Double basePrice;

    /**
     * 售价
     */
    private Double sellPrice;

    /**
     * 朋友价
     */
    private Double friendPrice;

    /**
     * 库存数量
     */
    private Long quantity;

    /**
     * 运费
     */
    private Double carriage;

    /**
     * 有效期开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date dateEnabled;

    /**
     * 有效期结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date dateDisabled;

    /**
     * 是否支持过期退
     */
    private Boolean refundable;

    /**
     * 条形码
     */
    private String barcode;

    /**
     * 是否立即开售
     */
    private Boolean sellnow;

    /**
     * 开售时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date dateSelling;

    /**
     * 限购数量
     */
    private Long limitCount;

    /**
     * LOGO图
     */
    private String logoUrl;
    /**
     * LOGO图 多张
     */
    private List<String> logoUrls;

    /**
     * 卖点介绍
     */
    private String note;

    /**
     * 状态
     */
    private String status;


    /**
     * 平台ID
     */
    private Long mallId;

    /**
     * 商家ID
     */
    private Long merchantId;

    /**
     * 分销产品id
     */
    private Long marketId;

    /**
     * 服务费比率
     */
    private String serveRate;

    /**
     * 支持物流类型 SHOP_PICKUP("到店自取"),SHIPPING("物流"),SHOP_PICKUP_AND_SHIPPING("物流及到店自取")
     */
    private String shippingType;

    /**
     * 分销佣金
     */
    private Double resellFee;

    /**
     * 分享返利
     */
    private Double shareFee;

    /**
     * 分销产品 商家id
     */
    private Long marketMerchantId;

    /**
     * 平台属性
     */
    private String marketPlatformType;

    /**
     * 购买须知
     */
    private String manual;

    /**
     * 图文详情
     */
    private String introduce;

    /**
     * 产品来源类型(SELF:自营,MARKET:分销, ALL:全部)
     */
    private String productSourceType;

    /**
     * 查询状态
     */
    private Integer productStatus;

    /**
     * 产品编号/名称  (搜索)
     */
    private String keyword;

    /**
     * 访问数
     */
    private String viewCount;

    /**
     * 访客数
     */
    private Long customerCount;

    /**
     * 售出数
     */
    private Long saleCount;

    /**
     * 核销数
     */
    private Long verifyCount;

    /**
     * 产品分类
     */
    private Long categoryId;
    /**
     * 产品分类 ids
     */
    private List<Long> categoryIds;

    /**
     * 是否展示已分销产品 (YES:显示 NO:不显示)
     */
    private String showSaleProduct;

    /**
     * 按字段排序(date_created:发布时间 resell_fee:佣金 sell_price:售价 quantity:数量)
     */
    private String sortByName;

    /**
     * 降升序(DESC:降序 ASC:升序)
     */
    private String sort;

    /**
     * 是否已分销此产品
     */
    private String isSale;

    /**
     * C端访问URL
     */
    private String cAccessUrl;
    /**
     * 产品推广二维码图片路径
     */
    private String promoteUrl;

    /**
     * 产品适用门店类型(ALL:所有门店, PART:指定门店)
     */
    private String productMerchantStoreType;

    /**
     * 产品适用门店指定总数
     */
    private Long productMerchantStoreCount;

    /**
     * 品类名称
     */
    private String categoryName;

    /**
     * 最大价格
     */
    private String maxPrice;

    /**
     * 最小价格
     */
    private String minPrice;

    /**
     * 产品所属商家名称
     */
    private String merchantName;
    /**
     * 商家logoUrl;
     */
    private String ImgUrl;
    /**
     * 商家的分销码
     */
    private String salesCode;

    /**
     * 是否合作过(WAIT:发布时间 PASS:审核通过 REFUSE:没有合作关系)
     */
    private String marketMerchantCooperationStatus;

    /**
     * 是已否收藏
     */
    private Whether favourite = Whether.NO;

    /**
     * 审核内容
     */
    private String auditRemark;

    /**
     * 结算金额
     */
    private Double settleAmount;

    /**
     * 平台服务费
     */
    private Double serveFee;

    /**
     * 结算产品数量
     */
    private Long settleNum;

    /**
     * 购买者返利
     */
    private Double buyerFee;

    /**
     * 上架开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String beginDate;

    /**
     * 下架结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String endDate;

    /**
     * 购买数量
     */
    private Long buyNum;

    /**
     * 下架原因
     */
    private String productUnderReason;

    //分销产品 商家名称 冗余查询
    private String marketMerchantName;

    //礼包主产品ID
    private Long productId;

    //总佣金
    private Double sumResellFee;

    //总返利
    private Double sumShareFee;

    //好评数
    private String goodNew;

    //中评数
    private String middleNew;

    //差评数
    private String badNew;

    //好评率
    private String goodRate;

    //是否分销
    private Boolean isRecommend;

    //浏览量
    private Long pageView;

    //渠道码
    private String channelSalesCode;

    //产品别名
    private String aliasName;

    //排序
    private Long sortByNum;

    /**
     * 自定义方法 start ================================================================================
     */
    public String getStatusText() {
        if (StringUtils.isBlank(this.status)) {
            return null;
        }
        return ProductStatus.valueOf(this.status).getValue();
    }

    public String getTypeText() {
        if (StringUtils.isBlank(this.type)) {
            return null;
        }
        return ProductType.valueOf(this.type).getValue();
    }

    /**
     * 自定义方法 end ================================================================================
     */
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getBasePrice() {
        return basePrice;
    }

    public void setBasePrice(Double basePrice) {
        this.basePrice = basePrice;
    }

    public Double getSellPrice() {
        return sellPrice;
    }

    public void setSellPrice(Double sellPrice) {
        this.sellPrice = sellPrice;
    }

    public Long getQuantity() {
        return quantity;
    }

    public void setQuantity(Long quantity) {
        this.quantity = quantity;
    }

    public Double getCarriage() {
        return carriage;
    }

    public void setCarriage(Double carriage) {
        this.carriage = carriage;
    }


    public Boolean getRefundable() {
        return refundable;
    }

    public void setRefundable(Boolean refundable) {
        this.refundable = refundable;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public Boolean isSellnow() {
        return sellnow;
    }

    public void setSellnow(Boolean sellnow) {
        this.sellnow = sellnow;
    }

    public Long getLimitCount() {
        return limitCount;
    }

    public void setLimitCount(Long limitCount) {
        this.limitCount = limitCount;
    }

    public String getLogoUrl() {
        return logoUrl;
    }

    public void setLogoUrl(String logoUrl) {
        this.logoUrl = logoUrl;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public Date getLastUpdated() {
        return lastUpdated;
    }

    public void setLastUpdated(Date lastUpdated) {
        this.lastUpdated = lastUpdated;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public String getServeRate() {
        return serveRate;
    }

    public void setServeRate(String serveRate) {
        this.serveRate = serveRate;
    }

    public String getShippingType() {
        return shippingType;
    }

    public void setShippingType(String shippingType) {
        this.shippingType = shippingType;
    }

    public Double getResellFee() {
        return resellFee;
    }

    public void setResellFee(Double resellFee) {
        this.resellFee = resellFee;
    }

    public Double getShareFee() {
        return shareFee;
    }

    public void setShareFee(Double shareFee) {
        this.shareFee = shareFee;
    }

    public Long getMarketMerchantId() {
        return marketMerchantId;
    }

    public void setMarketMerchantId(Long marketMerchantId) {
        this.marketMerchantId = marketMerchantId;
    }

    public String getMarketPlatformType() {
        return marketPlatformType;
    }

    public void setMarketPlatformType(String marketPlatformType) {
        this.marketPlatformType = marketPlatformType;
    }

    public String getProductSourceType() {
        return productSourceType;
    }

    public void setProductSourceType(String productSourceType) {
        this.productSourceType = productSourceType;
    }

    public Integer getProductStatus() {
        return productStatus;
    }

    public void setProductStatus(Integer productStatus) {
        this.productStatus = productStatus;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public String getViewCount() {
        return viewCount;
    }

    public void setViewCount(String viewCount) {
        this.viewCount = viewCount;
    }

    public Long getSaleCount() {
        return saleCount;
    }

    public void setSaleCount(Long saleCount) {
        this.saleCount = saleCount;
    }

    public Long getVerifyCount() {
        return verifyCount;
    }

    public void setVerifyCount(Long verifyCount) {
        this.verifyCount = verifyCount;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public String getShowSaleProduct() {
        return showSaleProduct;
    }

    public void setShowSaleProduct(String showSaleProduct) {
        this.showSaleProduct = showSaleProduct;
    }

    public String getSortByName() {
        return sortByName;
    }

    public void setSortByName(String sortByName) {
        this.sortByName = sortByName;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }


    public String getIsSale() {
        return isSale;
    }

    public void setIsSale(String isSale) {
        this.isSale = isSale;
    }

    public Long getMarketId() {
        return marketId;
    }

    public void setMarketId(Long marketId) {
        this.marketId = marketId;
    }

    public String getManual() {
        return manual;
    }

    public void setManual(String manual) {
        this.manual = manual;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public List<String> getLogoUrls() {
        return logoUrls;
    }

    public void setLogoUrls(List<String> logoUrls) {
        this.logoUrls = logoUrls;
    }

    public List<Long> getCategoryIds() {
        return categoryIds;
    }

    public void setCategoryIds(List<Long> categoryIds) {
        this.categoryIds = categoryIds;
    }

    public List<Long> getMerchantStoreIds() {
        return merchantStoreIds;
    }

    public void setMerchantStoreIds(List<Long> merchantStoreIds) {
        this.merchantStoreIds = merchantStoreIds;
    }

    public Boolean getSellnow() {
        return sellnow;
    }

    public String getcAccessUrl() {
        return cAccessUrl;
    }

    public void setcAccessUrl(String cAccessUrl) {
        this.cAccessUrl = cAccessUrl;
    }

    public String getPromoteUrl() {
        return promoteUrl;
    }

    public void setPromoteUrl(String promoteUrl) {
        this.promoteUrl = promoteUrl;
    }

    public String getProductMerchantStoreType() {
        return productMerchantStoreType;
    }

    public void setProductMerchantStoreType(String productMerchantStoreType) {
        this.productMerchantStoreType = productMerchantStoreType;
    }

    public Long getProductMerchantStoreCount() {
        return productMerchantStoreCount;
    }

    public void setProductMerchantStoreCount(Long productMerchantStoreCount) {
        this.productMerchantStoreCount = productMerchantStoreCount;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public String getMaxPrice() {
        return maxPrice;
    }

    public void setMaxPrice(String maxPrice) {
        this.maxPrice = maxPrice;
    }

    public String getMinPrice() {
        return minPrice;
    }

    public void setMinPrice(String minPrice) {
        this.minPrice = minPrice;
    }

    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }

    public String getMarketMerchantCooperationStatus() {
        return marketMerchantCooperationStatus;
    }

    public void setMarketMerchantCooperationStatus(String marketMerchantCooperationStatus) {
        this.marketMerchantCooperationStatus = marketMerchantCooperationStatus;
    }

    public Date getDateEnabled() {
        return dateEnabled;
    }

    public void setDateEnabled(Date dateEnabled) {
        this.dateEnabled = dateEnabled;
    }

    public Date getDateDisabled() {
        return dateDisabled;
    }

    public void setDateDisabled(Date dateDisabled) {
        this.dateDisabled = dateDisabled;
    }

    public Date getDateSelling() {
        return dateSelling;
    }

    public void setDateSelling(Date dateSelling) {
        this.dateSelling = dateSelling;
    }

    public Whether getFavourite() {
        return favourite;
    }

    public void setFavourite(Whether favourite) {
        this.favourite = favourite;
    }

    public String getImgUrl() {
        return ImgUrl;
    }

    public void setImgUrl(String imgUrl) {
        ImgUrl = imgUrl;
    }

    public List<Long> getIds() {
        return ids;
    }

    public void setIds(List<Long> ids) {
        this.ids = ids;
    }

    public String getAuditRemark() {
        return auditRemark;
    }

    public void setAuditRemark(String auditRemark) {
        this.auditRemark = auditRemark;
    }


    public Long getSettleNum() {
        return settleNum;
    }

    public void setSettleNum(Long settleNum) {
        this.settleNum = settleNum;
    }

    public String getSalesCode() {
        return salesCode;
    }

    public void setSalesCode(String salesCode) {
        this.salesCode = salesCode;
    }

    public String getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(String beginDate) {
        this.beginDate = beginDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public Long getBuyNum() {
        return buyNum;
    }

    public void setBuyNum(Long buyNum) {
        this.buyNum = buyNum;
    }

    public String getProductUnderReason() {
        return productUnderReason;
    }

    public void setProductUnderReason(String productUnderReason) {
        this.productUnderReason = productUnderReason;
    }

    public String getMerchantStoreNames() {
        return merchantStoreNames;
    }

    public void setMerchantStoreNames(String merchantStoreNames) {
        this.merchantStoreNames = merchantStoreNames;
    }

    public String getMarketMerchantName() {
        return marketMerchantName;
    }

    public void setMarketMerchantName(String marketMerchantName) {
        this.marketMerchantName = marketMerchantName;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Double getSettleAmount() {
        return BigDecimalUtils.setScale(settleAmount);
    }

    public void setSettleAmount(Double settleAmount) {
        this.settleAmount = settleAmount;
    }

    public Double getServeFee() {
        return BigDecimalUtils.setScale(serveFee);
    }

    public void setServeFee(Double serveFee) {
        this.serveFee = serveFee;
    }

    public Double getBuyerFee() {
        return BigDecimalUtils.setScale(buyerFee);
    }

    public void setBuyerFee(Double buyerFee) {
        this.buyerFee = buyerFee;
    }

    public Double getSumShareFee() {
        return BigDecimalUtils.setScale(sumShareFee);
    }

    public void setSumShareFee(Double sumShareFee) {
        this.sumShareFee = sumShareFee;
    }

    public Double getSumResellFee() {
        return BigDecimalUtils.setScale(sumResellFee);
    }

    public void setSumResellFee(Double sumResellFee) {
        this.sumResellFee = sumResellFee;
    }

    public String getGoodNew() {
        return goodNew;
    }

    public void setGoodNew(String goodNew) {
        this.goodNew = goodNew;
    }

    public String getMiddleNew() {
        return middleNew;
    }

    public void setMiddleNew(String middleNew) {
        this.middleNew = middleNew;
    }

    public String getBadNew() {
        return badNew;
    }

    public void setBadNew(String badNew) {
        this.badNew = badNew;
    }

    public String getGoodRate() {
        return BigDecimalUtils.setScale(goodRate);
    }

    public void setGoodRate(String goodRate) {
        this.goodRate = goodRate;
    }

    public Boolean getRecommend() {
        return isRecommend;
    }

    public void setRecommend(Boolean recommend) {
        isRecommend = recommend;
    }

    public Long getPageView() {
        return pageView;
    }

    public void setPageView(Long pageView) {
        this.pageView = pageView;
    }

    public String getChannelSalesCode() {
        return channelSalesCode;
    }

    public void setChannelSalesCode(String channelSalesCode) {
        this.channelSalesCode = channelSalesCode;
    }

    public String getAliasName() {
        return aliasName;
    }

    public void setAliasName(String aliasName) {
        this.aliasName = aliasName;
    }

    public Double getFriendPrice() {
        return friendPrice;
    }

    public void setFriendPrice(Double friendPrice) {
        this.friendPrice = friendPrice;
    }

    public Long getCustomerCount() {
        return customerCount;
    }

    public void setCustomerCount(Long customerCount) {
        this.customerCount = customerCount;
    }

    public Long getSortByNum() {
        return sortByNum;
    }

    public void setSortByNum(Long sortByNum) {
        this.sortByNum = sortByNum;
    }

    @Override
    public String toString() {
        return "ProductDto{" +
                "ids=" + ids +
                ", type='" + type + '\'' +
                ", name='" + name + '\'' +
                ", merchantStoreIds=" + merchantStoreIds +
                ", merchantStoreNames='" + merchantStoreNames + '\'' +
                ", basePrice=" + basePrice +
                ", sellPrice=" + sellPrice +
                ", friendPrice=" + friendPrice +
                ", quantity=" + quantity +
                ", carriage=" + carriage +
                ", dateEnabled=" + dateEnabled +
                ", dateDisabled=" + dateDisabled +
                ", refundable=" + refundable +
                ", barcode='" + barcode + '\'' +
                ", sellnow=" + sellnow +
                ", dateSelling=" + dateSelling +
                ", limitCount=" + limitCount +
                ", logoUrl='" + logoUrl + '\'' +
                ", logoUrls=" + logoUrls +
                ", note='" + note + '\'' +
                ", status='" + status + '\'' +
                ", dateCreated=" + dateCreated +
                ", lastUpdated=" + lastUpdated +
                ", mallId=" + mallId +
                ", merchantId=" + merchantId +
                ", marketId=" + marketId +
                ", serveRate='" + serveRate + '\'' +
                ", shippingType='" + shippingType + '\'' +
                ", resellFee=" + resellFee +
                ", shareFee=" + shareFee +
                ", marketMerchantId=" + marketMerchantId +
                ", marketPlatformType='" + marketPlatformType + '\'' +
                ", manual='" + manual + '\'' +
                ", introduce='" + introduce + '\'' +
                ", productSourceType='" + productSourceType + '\'' +
                ", productStatus=" + productStatus +
                ", keyword='" + keyword + '\'' +
                ", viewCount='" + viewCount + '\'' +
                ", saleCount=" + saleCount +
                ", verifyCount=" + verifyCount +
                ", categoryId=" + categoryId +
                ", categoryIds=" + categoryIds +
                ", showSaleProduct='" + showSaleProduct + '\'' +
                ", sortByName='" + sortByName + '\'' +
                ", sort='" + sort + '\'' +
                ", isSale='" + isSale + '\'' +
                ", cAccessUrl='" + cAccessUrl + '\'' +
                ", promoteUrl='" + promoteUrl + '\'' +
                ", productMerchantStoreType='" + productMerchantStoreType + '\'' +
                ", productMerchantStoreCount=" + productMerchantStoreCount +
                ", categoryName='" + categoryName + '\'' +
                ", maxPrice='" + maxPrice + '\'' +
                ", minPrice='" + minPrice + '\'' +
                ", merchantName='" + merchantName + '\'' +
                ", ImgUrl='" + ImgUrl + '\'' +
                ", salesCode='" + salesCode + '\'' +
                ", marketMerchantCooperationStatus='" + marketMerchantCooperationStatus + '\'' +
                ", favourite=" + favourite +
                ", auditRemark='" + auditRemark + '\'' +
                ", settleAmount=" + settleAmount +
                ", serveFee=" + serveFee +
                ", settleNum=" + settleNum +
                ", buyerFee=" + buyerFee +
                ", beginDate='" + beginDate + '\'' +
                ", endDate='" + endDate + '\'' +
                ", buyNum=" + buyNum +
                ", productUnderReason='" + productUnderReason + '\'' +
                ", marketMerchantName='" + marketMerchantName + '\'' +
                ", productId=" + productId +
                ", sumResellFee=" + sumResellFee +
                ", sumShareFee=" + sumShareFee +
                ", goodNew='" + goodNew + '\'' +
                ", middleNew='" + middleNew + '\'' +
                ", badNew='" + badNew + '\'' +
                ", goodRate='" + goodRate + '\'' +
                ", isRecommend=" + isRecommend +
                ", pageView=" + pageView +
                ", channelSalesCode='" + channelSalesCode + '\'' +
                ", aliasName='" + aliasName + '\'' +
                '}';
    }
}
